package com.hq.thread.test2;

/**
 * @ClassName Test2
 * @Description
 * 所谓对象锁，就是就是synchronized 给某个对象加锁。
 * @Author huangzl
 * @Date 2019/4/8 12:56
 * @Version 1.0
 **/
public class Test2 {


    public static void main(String[] args) {
        MyObject myObject = new MyObject();

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                myObject.method1();
            }
        });

        t1.start();

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                myObject.method2();
            }
        });

        t2.start();
    }

}